package com.yzh.homework.homework03;

/**
 * @author 于振晗
 * @title: Book
 * @description: TODO 图书封装
 * @date 2020年08月25日
 * @path com.yzh.book
 */
public class Book {
    private  String bookName;//书名
    private String author;//作者
    private String publisher;//出版社
    private double price;//

    public Book() {
    }

    public Book(String bookName, String author, String publisher, double price) {
        this.bookName = bookName;
        this.author = author;
        this.publisher = publisher;
        this.setPrice(price);
    }

    public String getBookName() {
        return bookName;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getPublisher() {
        return publisher;
    }

    public void setPublisher(String publisher) {
        this.publisher = publisher;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        if(price<10){
            System.out.println("图书价格不能低于10元");
            price = 10;
        }
        this.price = price;
    }

    public void introduce(){
        System.out.println("书名："+this.bookName);
        System.out.println("作者："+this.author);
        System.out.println("出版社："+this.publisher);
        System.out.println("价格："+this.price);
    }
}

class Test{
    public static void main(String[] args) {
        Book book = new Book();
        book.setBookName("鹿鼎记");
        book.setAuthor("金庸");
        book.setPublisher("人民文学出版社");
        book.setPrice(120);
        book.introduce();
        System.out.println("===============================");
        Book book1 = new Book("绝代双骄", "古龙", "中国长安出版社", 9);
        book1.introduce();
    }
}